package com.depthsdata.coe.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import com.depthsdata.coe.dao.BusinessProcessDAOQueryBean;
import com.depthsdata.coe.service.BusinessProcessBean;
import com.depthsdata.coe.service.IBusinessProcessService;
import com.ourteam.frame.controller.AbstractCRUDServiceController;

@Controller
@CrossOrigin
@RequestMapping("/api/COE/businessProcess")
public class BusinessProcessManageAPI extends
		AbstractCRUDServiceController<BusinessProcessDAOQueryBean, BusinessProcessSearchBean, BusinessProcessBean> {

	@Autowired
	private IBusinessProcessService businessProcessService;

	@Override
	protected BusinessProcessDAOQueryBean newQueryBean() {
		return new BusinessProcessDAOQueryBean();
	}

	@Override
	protected int queryCount(BusinessProcessDAOQueryBean queryBean) throws Exception {
		return businessProcessService.queryBusinessProcessCount(queryBean);
	}

	@Override
	protected BusinessProcessBean[] queryData(BusinessProcessDAOQueryBean queryBean) throws Exception {
		return businessProcessService.queryBusinessProcesss(queryBean);
	}

	@Override
	protected void deleteData(long[] ids) throws Exception {

		businessProcessService.deleteBusinessProcesss(ids);

	}

	@Override
	protected BusinessProcessBean getDataById(long id) throws Exception {
		return businessProcessService.getBusinessProcessById(id);
	}

	@Override
	protected void saveData(BusinessProcessBean dataBean) throws Exception {

		if (dataBean.getId() == 0) {
			businessProcessService.addNewBusinessProcess(dataBean);
		} else {
			businessProcessService.modifyBusinessProcess(dataBean);
		}

	}

}
